{% extends 'base.html' %}
{% block content %}
    <div class="page-header">
        <h1>LuffyCity
            <small>BookManage</small>
        </h1>
    </div>

    <div class="container">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <a href="{% url 'app01:addbook' %}" class="btn btn-primary">添加书籍</a>
                <table class="table table-striped table-bordered mytable">
                    <thead>
                    <tr>
                        <th>书籍名称</th>
                        <th>价格</th>
                        <th>出版日期</th>
                        <th>出版社</th>
                        <th>作者</th>
                        <th>删除操作</th>
                        <th>编辑操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    {% for my_book in book_list %}
                        <tr>
                            <td>{{ my_book.title }}</td>
                            <td>{{ my_book.price }}</td>
                            <td>{{ my_book.pub_date|date:'Y-m-d' }}</td>
                            <td>{{my_book.publish.name }}</td>
                            <td>
                                {% for aut in my_book.authors.all %}
                                    {% if forloop.last %}
                                        <span>{{ aut.name }}</span>
                                    {% else %}
                                        <span>{{ aut.name }},</span>
                                    {% endif %}
                                {% endfor %}
                            </td>
                            <td><a href="{% url 'app01:delete' my_book.nid %}" class="btn btn-danger">删除</a></td>
                            <td><a href="{% url 'app01:modify' my_book.nid %}" class="btn btn-info">编辑</a></td>
                        </tr>

                    {% endfor %}

                    </tbody>

                </table>
            <a href="{% url 'app01:books' %}" class="btn btn-success center-block">返回</a>

            </div>
        </div>
    </div>
{% endblock %}